package com.hopu.blb_erp.service.impl;

import com.hopu.blb_erp.mapper.RoleMapper;
import com.hopu.blb_erp.entity.Role;
import com.hopu.blb_erp.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RoleServiceImpl implements RoleService {

    @Autowired
    private RoleMapper roleMapper;

    @Override
    public List<Role> findByName(String username) {
        return roleMapper.selectByName(username);
    }

    @Override
    public List<Role> findAll() {
        return roleMapper.selectAll();
    }

    @Override
    public Integer findCount() {
        return roleMapper.selectCount();
    }

    @Override
    public List<Role> findPage(Integer current, Integer pageSize) {
        return roleMapper.selectPage(current,pageSize);
    }

    @Override
    public Role findById(String id) {
        return roleMapper.selectById(id);
    }

    @Override
    public void add(Role role) {
        roleMapper.insert(role);
    }

    @Override
    public void removeById(String id) {
        roleMapper.deleteById(id);
    }

    @Override
    public void modifyById(Role role) {
        roleMapper.updateById(role);
    }

    @Override
    public Long findRoleName(String roleName) {
        return roleMapper.selectRoleName(roleName);
    }
}
